﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Sale_and_manage
{
    public partial class Mainform : DevComponents.DotNetBar.Office2007RibbonForm
    {
        private int childFormNumber = 0;

        public Mainform()
        {
            InitializeComponent();
        }

        public static string UserID;

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }



        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        public Boolean CheckAministrator(string ID)
        {
            if (ID == "admin")
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private void Mainform_Load(object sender, EventArgs e)
        {
            this.Visible = false;
            Login frm = new Login();
            frm.ShowDialog();
            if (this.IsDisposed != true)
            {
                this.Visible = true;
                tabUser.Text = UserID;
                if (!CheckAministrator(UserID))
                {
                    rbbAministrator.Enabled = false;
                }
            }
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            frmBookSearch frm = new frmBookSearch();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnFilter_Click(object sender, EventArgs e)
        {
            frmBookFilter frm = new frmBookFilter();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnShowBillList_Click(object sender, EventArgs e)
        {
            frmBillHistory frm = new frmBillHistory();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnAddNewCustomer_Click(object sender, EventArgs e)
        {
            frmAddGuest frm = new frmAddGuest();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnShowCustomerList_Click(object sender, EventArgs e)
        {
            frmManageGuest frm = new frmManageGuest();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnAddOrder_Click(object sender, EventArgs e)
        {
            frmAddOrder frm = new frmAddOrder();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnBookReport_Click(object sender, EventArgs e)
        {
            frmBookReport frm = new frmBookReport();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnOrderReport_Click(object sender, EventArgs e)
        {
            frmOrderReport frm = new frmOrderReport();
            frm.MdiParent = this;
            frm.Show(); ;
        }

        private void btnExportGuest_Click(object sender, EventArgs e)
        {
            frmGuestReport frm = new frmGuestReport();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnExportBook_Click(object sender, EventArgs e)
        {
            frmBookInfoExport frm = new frmBookInfoExport();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnAddProject_Click(object sender, EventArgs e)
        {
            frmAddNewProject frm = new frmAddNewProject();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnLogout_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            Login frm = new Login();
            frm.ShowDialog();
            if (this.IsDisposed != true)
            {
                this.Visible = true;
                tabUser.Text = UserID;
                this.Activate();
                tabManage.Checked = true;
                if (UserID == "admin")
                {
                    rbbAministrator.Enabled = true;
                }
                else
                {
                    rbbAministrator.Enabled = false;
                }
            }
        }

        private void btnShowOrderList_Click(object sender, EventArgs e)
        {
            frmOrderHistory frm = new frmOrderHistory();
            frm.MdiParent = this;
            frm.Show();
        }




    }
}
